Struct Vs Class When To Use Which
4 sectionsRapid overview
Struct Vs Class When To Use Which
TL;DR
| Feature | struct | class | | -------------------------- | ----------------------------------------------------------β¦
Read βHow it works
TODO: explain the mental model.
Read βQuick recall Q&A
Q: When should you choose a struct over a class? A: When the data is small (β€16 bytes), immutable, frequently created, and benefits from value semantics. Structs reduce GC pressure by living inline and being collected with stack frames. Itsβ¦
Read βAdditional notes
Example:
Read β